package com.badlogic.androidgames.mypirates.Sprite;

import java.util.Random;

import android.graphics.Point;
import android.graphics.Rect;

import com.badlogic.androidgames.framework.Game;

public class BasicEnemy extends Ship{

	Random random;
	
	public BasicEnemy(Game game, int x, int y) {
		super(game);
		this.x = x;
		this.y = y;
	}

	public void Initialize(){
		super.Initialize("redpirate.png", new Rect(0,0,50,50), new Point(1, 8), new Point(x, y));
		random = new Random();
	}
	
	public Point getNextMove(int playerX, int playerY){
		int deltaX = Math.abs(x - playerX);
		int deltaY = Math.abs(y - playerY);
		Point returnPoint = new Point(x, y);
		int side = -1;
		
		if(deltaX == deltaY)
			side = random.nextInt(2);
		if(deltaX > deltaY || side == 0){
			if(playerX > x)
				returnPoint.x = x + 1;
			else
				returnPoint.x = x - 1;
		}
		else if(deltaY > deltaX || side == 1){
			if(playerY > y)
				returnPoint.y = y + 1;
			else
				returnPoint.y = y - 1;
		}
		
		return returnPoint;
	}
}
